<script setup lang="ts">
import {
  ArrowLeft,
  ArrowRight,
  Delete,
  Edit,
  Share,
  Tickets,
} from "@element-plus/icons-vue";
import { reactive, ref } from "vue";
import { EquipmentData, parkTreeList } from "./data";
import { parkList } from "@/utils/const"
import { useSystemStore } from "@/hooks/usePinia";

const systemOpt = useSystemStore()
systemOpt.setPageName("园区管理")

const handleNodeClick = (data: Tree) => {
  console.log(data);
};

const defaultProps = {
  children: "children",
  label: "label",
};

const value = ref("");
const formInline = reactive({
  parkId: "",
  houseId: "",
});
</script>

<template>
  <div class="park-management">
    <el-row>
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="园区：">
          <el-select
            v-model="formInline.parkId"
            class="m-2"
            placeholder="园区"
            size="large"
            style="width: 240px"
          >
            <el-option
              v-for="item in parkList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="楼栋：">
          <el-select
            v-model="formInline.houseId"
            class="m-2"
            placeholder="楼栋"
            size="large"
            style="width: 240px"
          >
            <el-option
              v-for="item in parkList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button>搜索</el-button>
        </el-form-item>
      </el-form>
    </el-row>
    <el-row class="park-management__context">
      <el-col :span="4" class="park-management__context-tree">
        <el-tree
          accordion
          :data="parkTreeList"
          :props="defaultProps"
          @node-click="handleNodeClick"
        />
      </el-col>
      <el-col :span="20" class="park-management__context-list">
        <el-table :data="EquipmentData" style="width: 100%">
          <el-table-column prop="date" label="设备型号" width="180" />
          <el-table-column prop="name" label="客户名称" width="180" />
          <el-table-column prop="address" label="位置" />
          <el-table-column fixed="right" label="操作" width="160">
            <template #default>
              <el-button-group class="ml-4">
                <el-button size="small" type="" :icon="Edit" />
                <el-button size="small" type="primary" :icon="Tickets" />
                <el-button size="small" type="danger" :icon="Delete" />
              </el-button-group>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          class="park-management__context-list--pagination"
          small
          hide-on-single-page
          layout="prev, pager, next"
          :total="50"
        />
      </el-col>
    </el-row>
  </div>
</template>

<style lang="scss" scoped>
.park-management {
  &__context {
    &-list {
      &--pagination {
        justify-content: end;
      }
    }
  }
}
</style>
